home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 29
/
Volume 29 - JOGO DISK .iso
/
Games
/
jungle_adventure.swf
/
scripts
/
__Packages
/
GDK
/
Base.as
next >
Wrap
Text File
|
2006-11-29
|
5KB
|
186 lines
class GDK.Base extends MovieClip
{
var previewClip = false;
var paused = false;
var width = 100;
var height = 100;
var halfWidth = 50;
var halfHeight = 50;
var version = "GDK 1,3,80,0";
var running = false;
var maxFrameTime = 0.05;
var lastElapsed = 0.005;
var maxTimeDifference = 0.005;
function Base()
{
super();
new GDK.EventSubscriber(this);
this.worlds = new GDK.Collection();
if(this.useMask)
{
this.setMask(this.attachMovie("Square","mcMask",13421568));
}
GDK.Base.root = this;
this.tabChildren = false;
this.setSize(Math.round(this._xscale),Math.round(this._yscale));
this._yscale = this._xscale = 100;
this.previewClip = this._parent._name == "contents";
if(!this.previewClip)
{
for(var _loc3_ in this)
{
if(_loc3_.indexOf("mcDead") != -1)
{
this[_loc3_].swapDepths(1048575);
this[_loc3_].removeMovieClip();
}
}
}
}
function setSize(w, h, noEvent)
{
if(w == this.width && h == this.height)
{
return undefined;
}
this.halfWidth = w * 0.5;
this.halfHeight = h * 0.5;
if(noEvent)
{
this.width = w;
this.height = h;
}
else
{
this.sendEvent("Resize",this.width = w,this.height = h,this.width,this.height);
}
if(this.useMask)
{
this.mcMask._xscale = w;
this.mcMask._yscale = h;
}
if(this.mcDead0)
{
this.mcDead0._xscale = w;
this.mcDead0._yscale = h;
}
}
function start()
{
if(this.engineIntervalID)
{
return undefined;
}
this.lastUpdate = getTimer();
this.engineIntervalID = setInterval(function(o)
{
o.update();
}
,0,this);
this.onStart();
this.sendEvent("Start");
this.running = true;
this.update();
}
function pause()
{
this.paused = true;
this.onPause();
this.sendEvent("Pause");
this.update();
}
function resume()
{
this.paused = false;
this.onResume();
this.sendEvent("Resume");
this.update();
}
function stop()
{
this.running = false;
clearInterval(this.engineIntervalID);
delete this.engineIntervalID;
this.onStop();
this.sendEvent("Stop");
}
function update()
{
if(this.paused)
{
this.lastUpdate = getTimer();
return undefined;
}
var _loc2_ = Math.min(this.maxFrameTime,(this.lastUpdate - (this.lastUpdate = getTimer())) * -0.001);
_loc2_ = this.lastElapsed - Math.max(- this.maxTimeDifference,Math.min(this.maxTimeDifference,this.lastElapsed - _loc2_));
this.activeWorld.update(_loc2_);
this.activeWorld.render(_loc2_);
this.onUpdate();
this.sendEvent("Update",this.lastElapsed = _loc2_);
}
function getWorld(name)
{
var _loc2_ = this.worlds.length;
while((_loc2_ = _loc2_ - 1) > -1)
{
if(this.worlds[_loc2_].name == name)
{
return this.worlds[_loc2_];
}
}
return null;
}
function addWorld(worldObj)
{
if(!this.worlds.addMember(worldObj))
{
return undefined;
}
worldObj.displayNode = this;
worldObj.engine = this;
}
function removeWorld(worldObj)
{
var _loc2_ = this.worlds.length;
while((_loc2_ = _loc2_ - 1) > -1)
{
if(this.worlds[_loc2_] == worldObj)
{
this.worlds.splice(_loc2_,1);
}
}
delete this.worlds[worldObj.name];
worldObj.removeFromScene();
}
function removeAllWorlds()
{
this.activeWorld.removeFromScene();
this.activeWorld = null;
var _loc2_ = this.worlds.length;
while((_loc2_ = _loc2_ - 1) > -1)
{
this.worlds[_loc2_].removeFromScene();
}
this.worlds = new GDK.Collection();
}
function setActiveWorld(worldObj)
{
if(this.activeWorld == worldObj)
{
return undefined;
}
this.activeWorld.removeFromScene();
this.activeWorld = worldObj;
worldObj.addToScene();
worldObj.update(0.0001);
this.onWorldChanged();
this.sendEvent("WorldChanged");
}
function onUnload()
{
this.stop();
this.sendEvent("Unload");
this.setActiveWorld(null);
}
}